import java.util.Scanner;

public class Java014 {
    public static void main(String[] args) {
        int i,y,m,d;
        Scanner sc=new Scanner(System.in);
        System.out.println("Input time:y m d");
        y=sc.nextInt();
        m=sc.nextInt();
        d=sc.nextInt();
        fun(y,m,d);
    }
    public static void fun(int y,int m,int d){
        int flag=0,allDay=0;
        if(y%4==0){
            //闰1
            flag=1;
            if(y%100==0&&y%400!=0){
                //不是闰
                flag=0;
            }
        }
            switch (m) {
                case 1:
                    allDay += d;
                    break;
                case 2:
                    allDay = d+31;
                    break;
                case 3:
                    allDay = d+59;
                    break;
                case 4:
                    allDay = d+90;
                    break;
                case 5:
                    allDay += d+120;
                    break;
                case 6:
                    allDay += d+151;
                    break;
                case 7:
                    allDay += d+181;
                    break;
                case 8:
                    allDay += d+212;
                    break;
                case 9:
                    allDay += d+243;
                    break;
                case 10:
                    allDay += d+273;
                    break;
                case 11:
                    allDay += d+304;
                    break;
                case 12:
                    allDay += d+234;
                    break;
            }
        if(flag==1&&m>2){
            allDay+=1;
        }
        System.out.println(allDay);
    }
}
